Declare Function SQLAllocEnv Lib "odbc.dll" (env As Long) As Integer
Declare Function SQLDataSources Lib "ODBC.DLL" (ByVal henv As Long, ByVal fdir As Integer, ByVal szDSN As String, ByVal cbDSNMAx As Integer, pcbDSN As Integer, ByVal szDesc As String, ByVal cbDescMax As Integer, pcbDesc As Integer) As Integer
Sub CancelButton_Click ()
gfDBOpenFlag = False
Unload Me
End Sub
Sub cDBName_Click ()
On Error Resume Next
Dim tmp As String
Dim x As Integer
cDataBase = ""
cUserName = ""
cPassword = ""
'get the database name if there is one
tmp = String$(255, 32)
x = OSGetPrivateProfileString(cDBName, "database", "", tmp, Len(tmp), "ODBC.INI")
cDataBase = Mid$(tmp, 1, x)
'get the last user name is there is one
tmp = String$(255, 32)
x = OSGetPrivateProfileString(cDBName, "lastuser", "", tmp, Len(tmp), "ODBC.INI")
cUserName = Mid$(tmp, 1, x)
cPassword = ""
If cUserName <> "" Then
cPassword.SetFocus
Else
cDataBase.SetFocus
End If
End Sub
Sub Form_Load ()
Left = (Screen.Width - Width) / 2
Top = (Screen.Height - Height) / 2
GetDataSources cDBName
MsgBar "Enter DataBase Parameters", False
BeenLoaded = True
End Sub
Sub Form_Paint ()
Outlines Me
End Sub
Sub Form_Unload (Cancel As Integer)
MsgBar "", False
End Sub
'
'this routine fills a list box with all available
'ODBC data sources found in ODBC.INI
'
Sub GetDataSources (listctrl As Control)
Dim DataSource As String, Description As String
Dim DataSourceLen As Integer, DescriptionLen As Integer